﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace FuseTester
{
    class CreationScreen : Game
    {
        KeyboardState oldKeyboardState;
        public int ScreenSelection;

        Sprite background;
        //add other buttons

        SpriteBatch sb;
        GraphicsDeviceManager graphics;

        public CreationScreen(GraphicsDeviceManager graphics)
        {
            this.graphics = graphics;
        }

        public void LoadContent(ContentManager contentManager)
        {
            background.LoadContent(contentManager, "CreationMenuBackground");
            ScaleBackground(background);

        }

        public void Initialize()
        {
            sb = new SpriteBatch(graphics.GraphicsDevice);

            ScreenSelection = MyConstants.ICreationScreen;

            background = new Sprite(graphics);

            background.SetX(0);
            background.SetY(0);
            
            base.Initialize();
        }

        public void Update(GameTime gameTime)
        {
            Draw();

            oldKeyboardState = Keyboard.GetState();

            base.Update(gameTime);
        }

        public void Draw()
        {
            //first line may be inefficient
            //ScaleBackground(background);
            background.Draw(sb);


        }

        private void ScaleBackground(Sprite backgroundSprite)
        {
            Vector2 tempScale;
             
            tempScale.Y = ((float)this.graphics.PreferredBackBufferHeight / (float)backgroundSprite.Size.Height);
            tempScale.X = ((float)this.graphics.PreferredBackBufferWidth / (float)backgroundSprite.Size.Width);
           
            backgroundSprite.SetScale(tempScale);
        }
    }
}
